package com.yanqu.road.server.cmd.wingroom;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2022/2/11 11:07
 */
@Cmd(code = CrossProtocol.C_WING_ROOM_GET_OTHER_PLAYER_EVENT_REWARD, desc = "领取其他玩家厢房事件的奖励")
public class GetOtherPlayerEventRewardReqCrossCmd extends CrossCommand {
    private long otherPlayerServerId;
    private long otherPlayerId;
    private int pos;
    private String playerName;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WingRoomProto.GetOtherPlayerEventReqCrossMsg reqCrossMsg = WingRoomProto.GetOtherPlayerEventReqCrossMsg.parseFrom(packet.getBytes());
        WingRoomProto.GetOtherPlayerEventRewardReqMsg reqMsg = reqCrossMsg.getReqMsg();
        otherPlayerServerId = reqMsg.getOtherPlayerServerId();
        otherPlayerId = reqMsg.getOtherPlayerId();
        pos = reqMsg.getPos();
        playerName = reqCrossMsg.getPlayerName();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        WingRoomProto.GetOtherPlayerEventRewardCrossForwardMsg.Builder forwardMsg = WingRoomProto.GetOtherPlayerEventRewardCrossForwardMsg.newBuilder();
        forwardMsg.setOriPlayerId(packet.getPlayerId());
        forwardMsg.setOriServerId(serverId);
        forwardMsg.setPlayerName(playerName);
        forwardMsg.setOtherPlayerId(otherPlayerId);
        forwardMsg.setPos(pos);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_WING_ROOM_GET_EVENT_REWARD_CROSS_REQ, forwardMsg);
        MessageHelper.sendPacket(otherPlayerServerId, otherPlayerId, message);
    }

    @Override
    public void sendData() {

    }
}
